home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / tstmess.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  4KB  |  118 lines

  1. {$X+,B-,V-}
  2. program test;
  3.  
  4. { Test program for the nwMess unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  5.  
  6. { Test the following nwMess functions:
  7.  
  8.   BroadcastToConsole
  9.   GetBroadcastMessage
  10.   GetBroadCastMode
  11.   SetBroadcastMode
  12.   SendBroadcastMessage
  13.   SendConsoleBroadcast
  14.  
  15. }
  16.  
  17. uses nwmisc,nwMess;
  18.  
  19. Var t,tbm,bm:byte;
  20.     connL,connResultL:TconnectionList;
  21.     mess    :string;
  22.  
  23. Procedure DisplayBrMode(bm:byte);
  24. begin
  25.  Case bm of
  26.  00: begin writeln('Server Stores : Netware Messages and User Messages,');
  27.            writeln('Shell automaticly displays messages.')
  28.      end;
  29.  01: begin writeln('Server Stores : Server Messages. (User messages discarded)');
  30.            writeln('Shell automaticly displays messages.')
  31.      end;
  32.  02: begin writeln('Server stores : Server messages only.');
  33.            writeln('Applications have to use GetBroadCastMessage to see if there is a message.')
  34.      end;
  35.  03: begin writeln('Server stores : Server messages and User messages.');
  36.            writeln('Applications have to use GetBroadCastMessage to see if there is a message.')
  37.      end;
  38.  else writeln('Unknown broadcastMode')
  39.  end; {case}
  40. end;
  41.  
  42. begin
  43. writeln;
  44. writeln('Testing BroadcastToConsole..');
  45. writeln('This will make the server beep ! (NOT an error this time)');
  46. writeln;
  47. writeln('<Return> to continue..');
  48. readln(mess);
  49.  
  50. if BroadcastToConsole('Hello, Console Operator!')
  51.  then writeln('BroadcastToConsole: Msg was broadcasted..')
  52.  else writeln('Broadcast To Console error:'+hexstr(nwMess.result,2));
  53.  
  54. writeln;
  55. if GetBroadcastMode(bm)
  56.  then begin
  57.       writeln('GetBroadcastMode: $',HexStr(bm,2));
  58.       DisplayBrMode(bm);
  59.  
  60.       t:=3;
  61.       while (t>=0) and (t<=3)
  62.        do if SetBroadcastMode(t) and GetBroadcastMode(tbm) and (tbm=t)
  63.            then dec(t) { ok, try next mode, alowed modes: 0,1,2,3 }
  64.            else begin
  65.                 writeln('SetBroadcastMode/GetBroadcastMode test failed.');
  66.                 t:=$80;
  67.                 end;
  68.  
  69.       if t=byte(-1)
  70.        then begin
  71.             SetBroadCastMode(bm); { restore old broadcastmode.. }
  72.             if nwmess.result=$00
  73.              then begin
  74.                   writeln;
  75.                   writeln('SetBroadcastMode tested OK..');
  76.                   end
  77.              else writeln('SetBroadcastMode error: Old mode couldn''t be restored..');
  78.             end;
  79.       end
  80.  else writeln('GetBroadcastMode error:'+hexstr(nwMess.result,2));
  81.  
  82. writeln;
  83. for t:=1 to 20 do connL[t]:=t;
  84. IF sendBroadcastMessage('Hello u there!',20,connL,connResultL)
  85.  then begin
  86.       writeln('SendBroadcastMessage: Msg was broadcasted..');
  87.       writeln('--and displayed at the folowing connections:');
  88.       for t:=1 to 20 do if connResultL[t]=$00 then write(t,' ');
  89.       writeln;
  90.       end
  91.  else writeln('SendBroadcastMessage error:'+hexstr(nwMess.result,2));
  92.  
  93. writeln;
  94. IF SendConsoleBroadcast('Testmessage from Console-operator..',0,connL)
  95.  then writeln('SendConsoleBroadcast: console message sent.')
  96.  else begin
  97.       write('SendConsoleBroadCast: Error ');
  98.       if nwMess.result=$C6
  99.        then writeln('! You need to have console privileges..')
  100.        else writeln(HexStr(nwMess.result,2));
  101.       end;
  102.  
  103. GetBroadCastMode(bm);
  104.  
  105. writeln;
  106. if SetBroadCastMode(3) { store all messages at the server, no notification.. }
  107.  then begin
  108.       writeln('Test of getBroadCastMessage..');
  109.       writeln('--use SEND on another workstation and send a message to this station.');
  110.       writeln;
  111.       writeln('Polling for a message.....');
  112.       REPEAT {} UNTIL GetBroadCastMessage(mess);
  113.       writeln('Message: ',mess);
  114.       end;
  115.  
  116. SetBroadCastMode(bm); { restore broadcastmode }
  117.  
  118. end.